package saeildamil.ch18.quiz2;

import java.util.Random;

public class SimulThread extends Thread {
	SharedArea sharedArea;
	@Override
	public void run() {
		int sum = 0;
		for(int cnt=0; cnt<1000000; cnt++){
			Random random = new Random();
			boolean isHead = random.nextBoolean();
			if(isHead)
				sum++;
		}
		sharedArea.ratio = sum/1000000.0;
		synchronized (sharedArea) {
			sharedArea.notify();
		}
	}
}
